home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / gag / walkingman.lha / WalkingMan / Sources / Mann.c < prev    next >
C/C++ Source or Header  |  1992-08-04  |  4KB  |  176 lines

  1. /* JPK13.04.92-30.04.92+05.05.92+22.05.92 */
  2.  
  3. #ifndef EXTERN_H
  4. #include "Extern.h"
  5. #endif
  6. #ifndef BILDSCHIRMANALYSE/ANALYSE_H
  7. #include "Bildschirmanalyse/Analyse.h"
  8. #endif
  9. #ifndef LISTENVERWALTUNG/LISTE_H
  10. #include "Listenverwaltung/Liste.h"
  11. #endif
  12. #ifndef BEWEGUNGSGENERATOR/BEWEGUNG_H
  13. #include "Bewegungsgenerator/Bewegung.h"
  14. #endif
  15. #ifndef DARSTELLUNG/DARSTELLUNG_H
  16. #include "Darstellung/Darstellung.h"
  17. #endif
  18.  
  19.  
  20.     /***** globale Variablen *****/
  21.  
  22. struct IntuitionBase *IntuitionBase;
  23. struct GfxBase *GfxBase;
  24.  
  25. struct Window *MyWindow;
  26.  
  27. struct Flags Flags;
  28.  
  29.  
  30.     /***** statische Daten *****/
  31.  
  32. UBYTE Titel[] = (UBYTE *)
  33.     "Wandersmann - ©Jan P.Katz/JPK MCMXCII. Version 22.05.92";
  34.  
  35. struct NewWindow MyNewWindow =
  36.     {
  37.     78,0,147,10, 0,1, 0L,WINDOWDRAG|WINDOWDEPTH|SMART_REFRESH,
  38.     0L,0L, Titel, 0L,0L, 100,10, 100,10, WBENCHSCREEN
  39.     };
  40.  
  41. struct IntuiText
  42.     QuitText =    {    0,1, JAM2, 20,1, 0L, (UBYTE *)"Quit", 0L    },
  43.     BreakText =    {    0,1, JAM2, 20,1, 0L, (UBYTE *)"Abbruch", 0L    },
  44.     NeuText =    {    0,1, JAM2, 20,1, 0L, (UBYTE *)"Neues Männchen",0L    },
  45.     AltText =    {    0,1, JAM2, 20,1, 0L, (UBYTE *)"Männchen entfernen",0L    };
  46.  
  47. struct MenuItem
  48.     NeuItem = {
  49.         0L, 0,0,176,10, ITEMTEXT|HIGHCOMP|CHECKIT|ITEMENABLED,
  50.         0L, (APTR)&NeuText,0L, '\0', 0L,0    },
  51.     AltItem = {
  52.         &NeuItem, 0,10,176,10, ITEMTEXT|HIGHCOMP|CHECKIT|ITEMENABLED,
  53.         0L, (APTR)&AltText,0L, '\0', 0L,0    },
  54.     BreakItem = {
  55.         &AltItem, 0,25,176,10, ITEMTEXT|HIGHCOMP|COMMSEQ|CHECKIT|ITEMENABLED,
  56.         0L, (APTR)&BreakText,0L, 'B', 0L,0    },
  57.     QuitItem = {
  58.         &BreakItem, 0,35,176,10, ITEMTEXT|HIGHCOMP|COMMSEQ|CHECKIT|ITEMENABLED,
  59.         0L, (APTR)&QuitText,0L, 'Q', 0L,0    };
  60.  
  61. struct Menu MyMenu = {
  62.     0L, 8,0,96,10, MENUENABLED, (BYTE *)Titel, &QuitItem,
  63.     0,0,0,0    };
  64.  
  65.  
  66.  
  67.     /***** Funktionen *****/
  68.  
  69. char Fehler()
  70.     {
  71.     DisplayBeep(0L);
  72.     DisplayBeep(0L);
  73.     return(0);
  74.     }
  75.  
  76. char StartUp(mannenzahl)
  77. WORD mannenzahl;
  78.     {
  79.     if(!(IntuitionBase = (struct IntuitionBase *)
  80.         OpenLibrary("intuition.library", 33L)))
  81.         {
  82.         printf("Konnte Intuition nicht öffnen.\n");
  83.         return(1);
  84.         }
  85.     if(!(GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 33L)))
  86.         {
  87.         printf("Konnte Graphics nicht öffnen.\n");
  88.         return(1);
  89.         }
  90.     if(!(MyWindow = OpenWindow(&MyNewWindow)))
  91.         {
  92.         printf("Kann das Fenster nicht öffnen.\n");
  93.         return(1);
  94.         }
  95.     SetWindowTitles(MyWindow, -1L, Titel);
  96.     SetMenuStrip(MyWindow, &MyMenu);
  97.     Bewegung_Init(mannenzahl);
  98.     return(0);
  99.     }
  100.  
  101.  
  102. void CleanUp()
  103.     {
  104.     Bewegung_Clear();
  105.     if(MyWindow)
  106.         {
  107.         ClearMenuStrip(MyWindow);
  108.         CloseWindow(MyWindow);
  109.         }
  110.     if(GfxBase) CloseLibrary(GfxBase);
  111.     if(IntuitionBase) CloseLibrary(IntuitionBase);
  112.     }
  113.  
  114.  
  115. void main(argc, argv)
  116. int argc;
  117. char *argv[];
  118.     {
  119.     WORD mannenzahl = 1;
  120.     if(argc>1)
  121.         {
  122.         char *zeichen = argv[1];
  123.         mannenzahl = 0;
  124.         while(*zeichen>='0' && *zeichen<='9')
  125.             {
  126.             mannenzahl = mannenzahl*10 + *zeichen - '0';
  127.             zeichen++;
  128.             }
  129.         if(*zeichen || argc>2)
  130.             {
  131.             printf(
  132. "Aufruf:\n"
  133. "   '%s [Anzahl der Männchen]'\n"
  134. "Bei fehlender oder fehlerhafter Anzahl der Männchen wird 1 gesetzt\n",
  135.                 argv[0]);
  136.             mannenzahl = 1;
  137.             }
  138.         }
  139.  
  140.  
  141.     if(!StartUp(mannenzahl))
  142.         {
  143.         Flags.quit = 0;
  144.         Flags.finale = 0;
  145.         while(!Flags.quit)
  146.             {
  147.             WaitTOF();
  148.             Bewegung_Schritt();
  149.             WaitTOF();
  150.             Bewegung_Halbschritt();
  151.             if(NeuItem.Flags&CHECKED)
  152.                 {
  153.                 NeuItem.Flags &= ~CHECKED;
  154.                 Bewegung_Neu();
  155.                 }
  156.             if(AltItem.Flags&CHECKED)
  157.                 {
  158.                 AltItem.Flags &= ~CHECKED;
  159.                 Bewegung_Alt((WORD)1);
  160.                 }
  161.             if(QuitItem.Flags&CHECKED)
  162.                 {
  163.                 if(!Flags.finale)
  164.                     {
  165.                     Flags.finale = 1;
  166.                     Bewegung_Alt((WORD)-1);
  167.                     }
  168.                 }
  169.             if(BreakItem.Flags&CHECKED)
  170.                 Flags.quit = 1;
  171.             }
  172.         }
  173.     CleanUp();
  174.     }
  175.  
  176.